#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=2e5+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//

void solve()
{
	int xa,ya,xb,yb,xc,yc;
	cin>>xa>>ya>>xb>>yb>>xc>>yc;

	int ans=abs(xa-xb)+abs(ya-yb);

	if(xa==xb&&xb==xc)
	{
		int mx=max(ya,yb);
		int mi=min(ya,yb);
		if(mi<=yc&&mx>=yc) ans+=2;
	}

	if(ya==yb&&ya==yc)
	{
		int mx=max(xa,xb);
		int mi=min(xa,xb);
		if(mi<=xc&&mx>=xc) ans+=2;
	}

	cout<<ans<<'\n';


	
}

int main()
{
	close();
	int T; cin>>T;
	while (T--) solve();
	return 0;
}